 <div id="breadcrumbs"><?php echo $this->Html->link('Home', array('controller' => 'contents', 'action' => 'view', 'home')); ?>> List Staff Book Entries
</div>
<?php
//super admin and admin view
if ($this->Session->read('Auth.User.role_id') == 1 || $this->Session->read('Auth.User.role_id') == 2) {
    ?>
    <div class="staffbooks index">
        <h2><?php echo __('Staff Book', array('controller' => 'Staffbooks', 'action' => 'index')); ?></h2>
        <table cellpadding="0" cellspacing="0">
            <tr>

                <th><?php echo $this->Paginator->sort('title'); ?></th>
                <th><?php echo $this->Paginator->sort('desc', 'Description'); ?></th>
                <th><?php echo $this->Paginator->sort('active'); ?></th>
                <th><?php echo $this->Paginator->sort('timestamp'); ?></th>
    <!--			<th class="actions"><?php echo __('Actions'); ?></th>-->
                <th>View</th>
                <?php if ($this->Session->read('Auth.User.role_id') == 1 || $this->Session->read('Auth.User.role_id') == 2) { ?>
                    <th>Edit</th>
                    <th>Delete</th>  
                <?php } ?>
            </tr>
            <?php foreach ($staffbooks as $staffbook): ?>
                <tr>    

                    <td><?php echo h($staffbook['Staffbook']['title']); ?>&nbsp;</td>
                    <td><?php echo h($staffbook['Staffbook']['desc']); ?>&nbsp;</td>
                    <td><?php
                        if ($staffbook['Staffbook']['active'] == 1)
                            echo "Yes";
                        else {
                            echo "No";
                        }
                        ?>&nbsp;</td>
                    <td><?php echo h($staffbook['Staffbook']['timestamp']); ?>&nbsp;</td>
                    <td><?php echo $this->Html->image('view.png', array('alt' => 'View', 'url' => array('action' => 'view', $staffbook['Staffbook']['id']))); ?></td>
                    <?php if ($this->Session->read('Auth.User.role_id') == 1 || $this->Session->read('Auth.User.role_id') == 2) { ?>
                        <td><?php echo $this->Html->image('edit.png', array('alt' => 'Edit', 'url' => array('action' => 'edit', $staffbook['Staffbook']['id']))); ?></td>
                        <td><?php echo $this->Form->postLink($this->Html->image('delete.png', array('alt' => __('Delete'))), array('action' => 'delete', $staffbook['Staffbook']['id']), array('escape' => false, 'confirm' => __('Are you sure you want to delete ' . $staffbook['Staffbook']['title'] . '?'))); ?> </td>
                    <?php } ?>
                </tr>
            <?php endforeach; ?>
        </table>
        <div class="paging">
        <?php
        echo $this->Paginator->prev('< ' . __('Previous'), array(), null, array('class' => 'prev disabled'));
        echo $this->Paginator->numbers(array('separator' => ''));
        echo $this->Paginator->counter(array('format' => __('Page {:page} of {:pages}')));
        echo $this->Paginator->next(__('Next') . ' >', array(), null, array('class' => 'next disabled'));
        ?>
    </div>
    </div><?php if ($this->Session->read('Auth.User.role_id') == 1 || $this->Session->read('Auth.User.role_id') == 2) { ?>
        <div class="actions">
            <h3><?php echo __('Actions'); ?></h3>
            <ul>
                <li><?php echo $this->Html->link(__('New Entry'), array('action' => 'add')); ?></li>
            </ul>
        </div><?php } ?>
    <?php
}
// staff view
else {
    ?>
        <h2><?php echo __('Staff Book', array('controller' => 'Staffbooks', 'action' => 'index')); ?></h2>
        <table cellpadding="0" cellspacing="0">
            <tr>
                <th></th>
                <th><?php echo $this->Paginator->sort('title'); ?></th>
                <th><?php echo $this->Paginator->sort('desc', 'Description'); ?></th>
                <th><?php echo $this->Paginator->sort('timestamp'); ?></th>
                <th>View</th>
            </tr>
            <?php foreach ($staffbooks as $staffbook): ?>
                <tr>
                    <td><?php
                        if (!empty($usersStaffbooks)) {
                            $flag = false;
                            foreach ($usersStaffbooks as $userStaffbook):

                                if ($userStaffbook['UsersStaffbook']['staffbook_id'] == $staffbook['Staffbook']['id']) {
                                    $flag = true;
                                    //echo $this->Html->image('Check.png', array('alt' => 'isRead', 'url' => array('action' => 'isRead', $staffbook['Staffbook']['id'])));
                                    //break;
                                }


                            endforeach;
                            if ($flag) {
                                echo $this->Html->image('Check.png', array('alt' => 'isRead', 'url' => array('action' => 'isRead', $staffbook['Staffbook']['id'])));
                            } else {
                                echo $this->Html->image('Exclamation.png', array('alt' => 'unRead', 'url' => array('action' => 'unRead', $staffbook['Staffbook']['id'])));
                            }
                        } else {
                            echo $this->Html->image('Exclamation.png', array('alt' => 'unRead', 'url' => array('action' => 'unRead', $staffbook['Staffbook']['id'])));
                        }
                        ?>&nbsp;</td>


                    <td><?php echo h($staffbook['Staffbook']['title']); ?>&nbsp;</td>
                    <td><?php echo h($staffbook['Staffbook']['desc']); ?>&nbsp;</td>
                    <td><?php echo h($staffbook['Staffbook']['timestamp']); ?>&nbsp;</td>
                    <td><?php echo $this->Html->image('view.png', array('alt' => 'View', 'url' => array('action' => 'view', $staffbook['Staffbook']['id']))); ?></td>
                    <?php if ($this->Session->read('Auth.User.role_id') == 1 || $this->Session->read('Auth.User.role_id') == 2) { ?>
                        <td><?php echo $this->Html->image('edit.png', array('alt' => 'Edit', 'url' => array('action' => 'edit', $staffbook['Staffbook']['id']))); ?></td>
                        <td><?php echo $this->Form->postLink($this->Html->image('delete.png', array('alt' => __('Delete'))), array('action' => 'delete', $staffbook['Staffbook']['id']), array('escape' => false, 'confirm' => __('Are you sure you want to delete ' . $staffbook['Staffbook']['title'] . '?'))); ?> </td>
                    <?php } ?>
                </tr>
            <?php endforeach; ?>
        </table>
        <div class="paging">
            <?php
            echo $this->Paginator->prev('< ' . __('Previous'), array(), null, array('class' => 'prev disabled'));
            echo $this->Paginator->numbers(array('separator' => ''));
            echo $this->Paginator->counter(array('format' => __('Page {:page} of {:pages}')));
            echo $this->Paginator->next(__('Next') . ' >', array(), null, array('class' => 'next disabled'));
            ?>
        </div>
    <?php if ($this->Session->read('Auth.User.role_id') == 1 || $this->Session->read('Auth.User.role_id') == 2) { ?>
        <div class="actions">
            <h3><?php echo __('Actions'); ?></h3>
            <ul>
                <li><?php echo $this->Html->link(__('New Entry'), array('action' => 'add')); ?></li>
            </ul>
        </div>
        <?php } ?>  
<?php }
?>

